<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <p class="welcome"></p>
</body>
<script>
    var wel = document.getElementsByClassName("welcome")[0];

    var a = getCookie("user");
    var users = JSON.parse(a);

    wel.innerText = `${users},欢迎您的到来!`;

    function getCookie(key){
        var cookie = document.cookie;
        if(cookie){
            var list = cookie.split("; ");//;后面有个空格*************
            for(var i = 0 ; i < list.length ; i++){
                var item = list[i];
                var attr = item.split("=")[0];
                var val = item.split("=")[1];
                if(key === attr){
                    return val;
                }
            }
        }
        return "";
    }
</script>
</html>